#!/bin/bash
function Usage() {
    echo "Usage: %0"
}

if [[ $# -ge 1 ]];then
    Usage
    exit 1
fi

NosTime=`date +"%Y-%m-%d %H:%M:%S"`

eval `df -T  -x tmpfs -x devtmpfs -x fuse.ossfs -x overlay -m | tail -n +2 | \
awk -v DiskSum=0 -v LeftSum=0 '{printf("parsum["NR"]=%d;parleft["NR"]=%d;parname["NR"]=%s;\
parusage["NR"]=%s;", $3, $5, $7, $6); DiskSum+=$3; LeftSum=$5} \
END {printf("parnum=%d;DiskSum=%d;LeftSum=%d;", NR, DiskSum, LeftSum)}'`

diskusage=`echo "scale=2; 100-${LeftSum}*100/${DiskSum}" | bc`
echo "${NowTime} 0 all ${DiskSum} ${LeftSum} ${diskusage}%"

for (( i = 1; i <= ${parnum}; i++ ));do
    echo "$NowTime 1 ${parname[$i]} ${parsum[$i]} ${parleft[$i]} ${parusage[$i]%s}"
done
